﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson.Serialization.Attributes;
using Ymatou.User.Dto.Auth;

namespace YmtAuth.Domain.Model.YmatouUser.Event
{
    /// <summary>
    /// login id update envent
    /// </summary>
    public class LoginIdUpdateEvent : Entity<string>
    {
        public LoginIdUpdateEvent(string newLoginId, int userId, string mobile, UserSource userSource = Ymatou.User.Dto.Auth.UserSource.MainSite)
        {
            if (string.IsNullOrEmpty(newLoginId)) throw new ArgumentNullException("newLoginId 不能为空");
            this.Id = Guid.NewGuid().ToString("N");
            this.ModifyDateTime = DateTime.Now;
            this.NewLoginId = newLoginId;
            this.UserSource = userSource;
            this.Mobile = mobile;
            this.UserId = userId;
        }
        [BsonElement("uId")]
        public int UserId { get; set; }
        [BsonElement("nId")]
        [BsonIgnoreIfNull]
        public string NewLoginId { get; private set; }
        [BsonElement("uSource")]
        [BsonIgnoreIfNull]
        public UserSource UserSource { get; private set; }
        [BsonElement("mobile")]
        [BsonIgnoreIfNull]
        public string Mobile { get; set; }
        [BsonIgnoreIfNull]
        [BsonElement("mDate")]
        public DateTime ModifyDateTime { get; private set; }

        protected LoginIdUpdateEvent() { }

        protected override IEnumerable<object> CompareValues()
        {
            yield return this.Id;
        }
    }
}
